package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsNewCommodity;
import com.mall.mapper.SmsNewCommodityMapper;
import com.mall.service.SmsNewCommodityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsNewCommodityServiceImpl extends ServiceImpl<SmsNewCommodityMapper, SmsNewCommodity> implements SmsNewCommodityService {

    @Resource
    private SmsNewCommodityMapper smsNewCommodityMapper;

    @Override
    public SmsNewCommodity getById(Integer id) {
        return smsNewCommodityMapper.selectById(id);
    }

    @Override
    public List<SmsNewCommodity> getAll() {
        return smsNewCommodityMapper.selectList(null);
    }

    @Override
    public boolean deleteById(Integer id) {
        return smsNewCommodityMapper.deleteById(id) > 0;
    }

    @Override
    public boolean save(SmsNewCommodity smsNewCommodity) {
        if(smsNewCommodity.getId() == null)
        {
            return smsNewCommodityMapper.insert(smsNewCommodity) > 0;
        }else{
            return  smsNewCommodityMapper.updateById(smsNewCommodity) > 0;
        }
    }
}
